﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace InicioDeSesion
{
    public partial class Fis : Form
    {
        public Fis()
        {
            InitializeComponent();
        }

        private void Fis_Load(object sender, EventArgs e)
        {
            label1.BackColor = Color.Transparent;
            label1.Parent = pictureBox1;

            label2.BackColor = Color.Transparent;
            label2.Parent = pictureBox1;

            label3.BackColor = Color.Transparent;
            label3.Parent = pictureBox1;

            label4.BackColor = Color.Transparent;
            label4.Parent = pictureBox1;

            label4.Visible = false;
        }

        private void biniciarsesion_Click(object sender, EventArgs e)
        {
            label4.Visible = false;
            string usuario = tbusuario.Text;
            string contraseña = tbcontraseña.Text;

            Program1.InisiarSesion(usuario, contraseña);

            if (Program1.ocultar)
            {
                this.Hide();
                if (Program1.admin)
                    MessageBox.Show("Modo Administrador");
            }
            if (Program1.ucmal)
            {
                tbusuario.Focus();
                label4.Visible = Program1.ucmal;
            }
        }
        private void tbusuario_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                tbcontraseña.Focus();
        }

        private void tbcontraseña_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                biniciarsesion.PerformClick();
        }

        private void tbcontraseña_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Tab)
                biniciarsesion.PerformClick();
        }

        private void bsalir_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
